package br.usp.ime.escola;

import org.nakedobjects.extended.Cardinality;
import org.nakedobjects.extended.Entity;
import org.nakedobjects.extended.RelationshipObject;
import org.nakedobjects.extended.Way;
import org.nakedobjects.object.AbstractNakedObject;
import org.nakedobjects.object.Title;
import org.nakedobjects.object.collection.ExtendedInternalCollection;
import org.nakedobjects.object.value.TextString;

@Entity
public class Aluno extends AbstractNakedObject {

	private static final long serialVersionUID = 1L;

	private final TextString nome = new TextString();

	@RelationshipObject(
			cardinality = Cardinality.ManyToMany, 
			relatedWith = Materia.class, 
			fieldRelatedName = "aluno", 
			way = Way.TwoWay, 
			compositeClass = Matricula.class, 
			compositeFieldName = "matriculas", 
			compositeFieldRelatedName = "materia")
	private final ExtendedInternalCollection matriculas = new ExtendedInternalCollection(
			"Matriculas", Matricula.class, this);

	public Title title() {
		return getNome().title();
	}

	public ExtendedInternalCollection getMatriculas() {
		return matriculas;
	}

	public TextString getNome() {
		return nome;
	}
}
